﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using prototype123.models;
using prototype123.controllers;

namespace prototype123.data_access
{

    // Connector class is a singleton class, meant to be used as the parameter 
    // for the constructor in any of the DAO classes.
    public class Connector
    {
        private static Connector instance; 
        private const string connectString = "Data Source=sparky;Initial Catalog=cps420_team2_dev;Persist Security Info=True;User ID=cps420team2;Password=team2";
        private SqlConnection connection;

        private Connector() 
        {
            connection = new SqlConnection(connectString);
            connection.Open();
        }

        public static Connector Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new Connector();
                }
                return instance;
            }
        }

        public SqlConnection Connection
        {
            get { return connection; }
        }
    }
}
